package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Member;

public class MemberSqlProvider {

    public String insertSelective(Member record) {
        BEGIN();
        INSERT_INTO("st_member");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }

        
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getSex() != null) {
            VALUES("sex", "#{sex,jdbcType=TINYINT}");
        }
        
        if (record.getBirthday() != null) {
            VALUES("birthday", "#{birthday,jdbcType=DATE}");
        }
        
        if (record.getNumber() != null) {
            VALUES("number", "#{number,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getSpare_money() != null) {
            VALUES("spare_money", "#{spare_money,jdbcType=DOUBLE}");
        }
        
        if (record.getLast_consume_money() != null) {
            VALUES("last_consume_money", "#{last_consume_money,jdbcType=DOUBLE}");
        }
        
        if (record.getConsume_time() != null) {
            VALUES("consume_time", "#{consume_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getNotice() != null) {
            VALUES("notice", "#{notice,jdbcType=VARCHAR}");
        }
        
        if (record.getCoupon() != null) {
            VALUES("coupon", "#{coupon,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            VALUES("picture", "#{picture,jdbcType=VARCHAR}");
        }
        
        if (record.getMember_notice() != null) {
            VALUES("member_notice", "#{member_notice,jdbcType=VARCHAR}");
        }
        
        if (record.getGift_points() != null) {
            VALUES("gift_points", "#{gift_points,jdbcType=INTEGER}");
        }
        
        if (record.getQq() != null) {
            VALUES("qq", "#{qq,jdbcType=VARCHAR}");
        }
        
        if (record.getEmily() != null) {
            VALUES("emily", "#{emily,jdbcType=VARCHAR}");
        }
        
        if (record.getLike() != null) {
            VALUES("like", "#{like,jdbcType=VARCHAR}");
        }
        
        if (record.getAddress() != null) {
            VALUES("address", "#{address,jdbcType=VARCHAR}");
        }
        
        if (record.getSpecifications() != null) {
            VALUES("Specifications", "#{specifications,jdbcType=VARCHAR}");
        }
        
        if (record.getGarde() != null) {
            VALUES("garde", "#{garde,jdbcType=VARCHAR}");
        }
        
        if (record.getGrouping() != null) {
            VALUES("grouping", "#{grouping,jdbcType=VARCHAR}");
        }
        
        if (record.getAnniversaries() != null) {
            VALUES("anniversaries", "#{anniversaries,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Member record) {
        BEGIN();
        UPDATE("st_member");

        
        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getSex() != null) {
            SET("sex = #{sex,jdbcType=TINYINT}");
        }
        
        if (record.getBirthday() != null) {
            SET("birthday = #{birthday,jdbcType=DATE}");
        }
        
        if (record.getNumber() != null) {
            SET("number = #{number,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getSpare_money() != null) {
            SET("spare_money = #{spare_money,jdbcType=DOUBLE}");
        }
        
        if (record.getLast_consume_money() != null) {
            SET("last_consume_money = #{last_consume_money,jdbcType=DOUBLE}");
        }
        
        if (record.getConsume_time() != null) {
            SET("consume_time = #{consume_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getNotice() != null) {
            SET("notice = #{notice,jdbcType=VARCHAR}");
        }
        
        if (record.getCoupon() != null) {
            SET("coupon = #{coupon,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            SET("picture = #{picture,jdbcType=VARCHAR}");
        }
        
        if (record.getMember_notice() != null) {
            SET("member_notice = #{member_notice,jdbcType=VARCHAR}");
        }
        
        if (record.getGift_points() != null) {
            SET("gift_points = #{gift_points,jdbcType=INTEGER}");
        }
        
        if (record.getQq() != null) {
            SET("qq = #{qq,jdbcType=VARCHAR}");
        }
        
        if (record.getEmily() != null) {
            SET("emily = #{emily,jdbcType=VARCHAR}");
        }
        
        if (record.getLike() != null) {
            SET("like = #{like,jdbcType=VARCHAR}");
        }
        
        if (record.getAddress() != null) {
            SET("address = #{address,jdbcType=VARCHAR}");
        }
        
        if (record.getSpecifications() != null) {
            SET("Specifications = #{specifications,jdbcType=VARCHAR}");
        }
        
        if (record.getGarde() != null) {
            SET("garde = #{garde,jdbcType=VARCHAR}");
        }
        
        if (record.getGrouping() != null) {
            SET("grouping = #{grouping,jdbcType=VARCHAR}");
        }
        
        if (record.getAnniversaries() != null) {
            SET("anniversaries = #{anniversaries,jdbcType=VARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}